package com.tlibrary.controller;

import com.google.gson.Gson;
import com.tlibrary.service.ShowbasicsService;
import com.tlibrary.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @Author：wcc
 * @Description：
 * @Date：Create in: 2019/2/21--10:31
 */
@Controller
@RequestMapping("/show")
public class showbasicsController {

    @Autowired
    private ShowbasicsService ss;

    @RequestMapping("/col")
    public void boxCol(HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        List commonQuery =ss.getcol();
         Gson gson = new Gson();
        String json = gson.toJson(commonQuery);
        ResponseUtil.toHtml(response, json);
    }

    @RequestMapping("/dept")
    public void boxDept(HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        List commonQuery =ss.getDept();
        Gson gson = new Gson();
        System.out.println(commonQuery);
        String json = gson.toJson(commonQuery);
        ResponseUtil.toHtml(response, json);
    }

    @RequestMapping("/getallcol")
    public void getallcol(HttpServletRequest request, HttpServletResponse response){
        List commonQuery=ss.getallcol();
        Gson gson = new Gson();
        String json = gson.toJson(commonQuery);
        ResponseUtil.toHtml(response, json);
    }

    @RequestMapping("/getCousers")
    public void getCouser(HttpServletRequest request, HttpServletResponse response){
        String id = request.getParameter("ID");
        List commonQuery=ss.getCousers(id);
        Gson gson = new Gson();
        System.out.println(commonQuery);
        String json = gson.toJson(commonQuery);
        ResponseUtil.toHtml(response, json);
    }

    @RequestMapping("/getCouserss")
    public void getCouserss(HttpServletRequest request, HttpServletResponse response){

        List commonQuery=ss.getCouserss();
        Gson gson = new Gson();
        System.out.println(commonQuery);
        String json = gson.toJson(commonQuery);
        ResponseUtil.toHtml(response, json);
    }


}
